package com.application.lucky.widget.popupwindow;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.application.lucky.R;
import com.application.lucky.widget.time.TimeSelectorView;

/**
 * create by liulp
 * on 2019-11-17 23:08
 */
public class FullTimeSelectPop extends PopupWindow {
    private TimeType curType;

    public enum TimeType {
        start, end
    }

    public FullTimeSelectPop(Context context, final SelectResultListener resultListener) {
        super(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        View contentView = LayoutInflater.from(context).inflate(R.layout.popu_timeselector, null);
        setContentView(contentView);
        setFocusable(true);// 取得焦点
        //点击推出,要设置backgroundDrawable
        setBackgroundDrawable(new BitmapDrawable());
        /**设置PopupWindow弹出和退出时候的动画效果*/
        //      mPopupWindow.setAnimationStyle(R.style.animotorPdop);
        setOutsideTouchable(true);

        TimeSelectorView timeSelectorView = contentView.findViewById(R.id.timeselector);
        timeSelectorView.setListener(new TimeSelectorView.TimeChangeListener() {
            @Override
            public void scrollFinish(String time) {
            }

            @Override
            public void onFinish(String time) {
                if (resultListener != null) {
                    resultListener.onSelectResult(time);
                }

                dismiss();
            }

            @Override
            public void onCancel() {
                dismiss();
            }
        });
    }

    public interface SelectResultListener {
        void onSelectResult(String time);
    }
}
